<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>コントロールパネル</title>
    
    <link href="./assets/styles/default.css" rel="stylesheet" />
	<script src="./assets/scripts/libs/jquery-1.7.1.min.js" type="text/javascript"></script>
        <script src="https://www.google.com/jsapi" type="text/javascript"></script>
	<script src="./assets/scripts/plugins/jquery.tagsinput.min.js" type="text/javascript"></script>
	<script src="./assets/scripts/import.js" type="text/javascript"></script>
        
    <script>
{literal}	
		back_to_search();
		
        google.load("visualization", "1", {packages:["corechart"]});
        $(function(){
            var chart = renderChart({
                "title":"",
                "datatable":".sortable",
                "item_title":0,
                "item_data1":1,
                "item_data2":3,
                "renderTo":'chart',
				"vDirection":-1,
				"height":500
            });
			
			$('.graph a').click(function(){
				var t = $(this).attr("rel");
				if(t == "table"){
					$('#chart').hide();
					$('.sortable').show();
				}else {
					if(t == "bar"){	
						chart.renderColumn();					
					}else {
						chart.renderLine();
					}
				}
			});
			
        });
{/literal}
    </script>
    
</head>
<body>

{include file='include/header.inc.html'}

<div id="container">
	<aside id="accordion">
    	<div id="aside_inner">
    		{include file='include/menu.inc.html'}
        </div>
    </aside>
    
    <article>
    	<h2><span>&nbsp;</span>Seo<p><a href="javascript:;">Open Plugins</a></p></h2>
        <nav>
        	<ul>
            	<li class="active"><a href="seo.php"><span>検索</span></a></li>
            	<li><a href="seo.php?op=regist"><span>登録</span></a></li>
			</ul>
        </nav>
        
        <section id="content">
        
        	<h3>参照</h3>
{if $phase == 'input' }
					<form name="fm" id="fm_category" action="works_form.php" method="post" enctype="multipart/form-data">
                        <h4><span>&nbsp;</span>基本情報</h4>
						<table class="formTable">
							<tbody>
								<tr>
									<th>登録日時</th>
									<td>
										{$forms.r_date|date_format:"%Y-%m-%d %H:%M"|escape}
									</td>
								</tr>
								<tr>
									<th>更新日時</th>
									<td>
										{$forms.u_date|date_format:"%Y-%m-%d %H:%M"|escape}
									</td>
								</tr>
								<tr>
									<th>ID</th>
									<td>
										{"%05d"|sprintf:$forms.id}
									</td>
								</tr>
								<tr>
									<th>キーワード</th>
									<td>
                                    	{$forms.keyword|escape}
									</td>
								</tr>
								<tr>
									<th>URL</th>
									<td>
										{$forms.url|escape}
									</td>
								</tr>
								<tr>
									<th>告知順位</th>
									<td>
										{$forms.rank|escape}
									</td>
								</tr>
								<tr>
									<th>告知順位連絡先</th>
									<td>
										{$forms.email|escape}
									</td>
								</tr>
							</tbody>
						</table>
                        
                        <h4 class="b10"><span>&nbsp;</span>レポート</h4>
                        
                        <ul class="btns activemenu graph float-left">
                        	<li class="btn left"><a href="javascript:;" rel="table" class="active"><em class="list">&nbsp;</em>リスト表示</a></li>
                        	<li class="btn right"><a href="javascript:;" rel="line"><em class="line">&nbsp;</em>線グラフ</a></li>
                        </ul>
                        
                        <p class="btn_dl float-right">
                        	<a href="javascript:;" onClick="csv_download();">
                                CSVダウンロード
                            </a>
                        </p>
                        
                        <div id="chart" class="display-none"></div>
                        
                        <table id="search_result" class="sortable">
                            <thead>
                                <tr>
                                    <th style="width:70px;text-align:center;">検索日</th>
                                    <th>Google</th>
                                    <th>Google前日比</th>
                                    <th>Yahoo</th>
                                    <th>Yahoo前日比</th>
                                </tr>
                    
                            </thead>
                            <tbody>
                            {assign var=google value=$forms.rank}
                            {assign var=yahoo value=$forms.rank}
                            {foreach item=r key=d from=$demo}
                                <tr>
                                    <td>{$d|date_format:"%Y/%m/%d"|escape}</td>
                                    <td>{$r.google}</td>
                                    {if $r.google < $google}<td class="down">↓</td>
                                    {elseif $r.google > $google}<td class="up">↑</td>
                                    {else}<td class="keep">←</td>{/if}
                                    {assign var=google value=$r.google}
                                    <td>{$r.yahoo}</td>
                                    {if $r.yahoo < $yahoo}<td class="down">↓</td>
                                    {elseif $r.yahoo > $yahoo}<td class="up">↑</td>
                                    {else}<td class="keep">←</td>{/if}
                                    {assign var=yahoo value=$r.yahoo}
                                </tr>
                            {/foreach}
                            </tbody>
                        </table>
                    
						<p class="button">
							<button type="button" id="btn_update" onClick="location.href='seo.php'"><span>戻る</span></button>
						</p>
						<input type="hidden" name="id" value="{$forms.id }" />
						<input type="hidden" name="mode" value="" />
					</form>
{/if }

        </section>
    </article>
    
</div>

{include file='include/footer.inc.html'}

<form method="post" action="seo.php" name="csv">
<input type="hidden" name="op" value="csv"/>
<input type="hidden" name="id" value="{$forms.id|escape}"/>
{foreach item=r key=d from=$demo}
<input type="hidden" name="google[{$d}]" value="{$r.google|escape}"/>
<input type="hidden" name="yahoo[{$d}]" value="{$r.yahoo|escape}"/>
{/foreach}
</form>
<script language="JavaScript">
function csv_download(){
	document.csv.submit();
}
</script>

</body>
</html>